import pytest
import config
from api.login import LoginAPI
from api.dept import DeptAPI
from common.assertutil import common_assert
from common.jsonutil import build_data


class TestDept:
    # 初始化
    token666 = None
    def setup_class(self):
        # 实例化接口类
        self.login_api = LoginAPI()
        self.dept_api = DeptAPI()
        # 登录成功
        response = self.login_api.login(config.login_data)
        TestDept.token666 = response.json().get("data")
        print(TestDept.token666)
    # 创建部门
    @pytest.mark.parametrize("dept_data,status_code,success,code,message",build_data(f"{config.BASE_PASH}/data/dept.json"))
    def test_insert_dept(self,dept_data,status_code,success,code,message):
        response = self.dept_api.insert_dept(dept_data,TestDept.token666)
        print(response.json())

        common_assert(response,status_code,success,code,message)